package com.lwk.springbootmybatisdemo2.controller;

import com.lwk.springbootmybatisdemo2.entity.User;
import com.lwk.springbootmybatisdemo2.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: leiwenkang02@meituan.com
 * @date: 2018/4/13
 * @time: 16:26
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/getUserInfo")
    public List<User> getUserInfo() {
        List<User> user = userService.getUserInfo();
        System.out.println(user.toString());
        return user;
    }

    @RequestMapping("/addUserInfo")
    public String addUserInfo() {
        User user = new User();
        user.setId(3);
        user.setName("cwh");
        userService.insert(user);
        return "success:"+user.toString();
    }


    @RequestMapping("/test")
    public String test() {
        return "test";
    }
}
